/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-12-08     xu       the first version
 */
#include "pin_id.h"
#include <drivers/pin.h>
#include <rtthread.h>
#include <stdint.h>

struct {
    uint8_t pin;
    const char* name;
} pin_map[] = {
    /* PA0-PA7 */
    PA0,
    "PA.0",
    PA1,
    "PA.1",
    PA2,
    "PA.2",
    PA3,
    "PA.3",
    PA4,
    "PA.4",
    PA5,
    "PA.5",
    PA6,
    "PA.6",
    PA7,
    "PA.7",

    /* PB0-PB5 */
    PB0,
    "PB.0",
    PB1,
    "PB.1",
    PB2,
    "PB.2",
    PB3,
    "PB.3",
    PB4,
    "PB.4",
    PB5,
    "PB.5",

    /* PE0-PE7 */
    PE0,
    "PE.0",
    PE1,
    "PE.1",
    PE2,
    "PE.2",
    PE3,
    "PE.3",
    PE4,
    "PE.4",
    PE5,
    "PE.5",
    PE6,
    "PE.6",
    PE7,
    "PE.7",

    /* PF0-PF6 */
    PF0,
    "PF.0",
    PF1,
    "PF.1",
    PF2,
    "PF.2",
    PF3,
    "PF.3",
    PF4,
    "PF.4",
    PF5,
    "PF.5",
    PF6,
    "PF.6",
};

void print_pins()
{
    for (int i = 0; i < sizeof(pin_map) / sizeof(pin_map[0]); i++) {
        uint8_t pin = pin_map[i].pin;
        const char* name = pin_map[i].name;
        uint8_t pin_id = rt_pin_get(name);
        rt_kprintf("name = %s, pin = %d, pin_id = %d\n", name, pin, pin_id);
    }
}
MSH_CMD_EXPORT(print_pins, print pin maps);
